package com.mergeades.chp08;

import java.util.concurrent.BrokenBarrierException;
import java.util.concurrent.CyclicBarrier;

public class CyclicBarrierTest02 {

    static CyclicBarrier cb = new CyclicBarrier(2, ()->{
        System.out.println("first");
    });

    public static void main(String[] args) throws BrokenBarrierException, InterruptedException {
        new Thread(()->{
            try {
                cb.await();
            } catch (Exception e) {
                e.printStackTrace();
            }
            System.out.println(1);
        }).start();

        cb.await();
        System.out.println(2);
    }
}
